import Taro from "@tarojs/taro";
//分成单个人的请求路径
const yanghaoHttp = "http://172.17.26.232:8888/";
const panchenHttp = "http://172.17.26.220:8888/";
const huangyingHttp = "http://172.17.26.218:8888/";
const wangfanghuaHttp = "http://172.17.26.226:8888/";
const huangyiHttp = "http://localhost:8888/";
const huyuxinHttp = "http://api.qincore.cn/";
const http = options => {
  let arr = options.url.split("/");
  let arr1 = arr.slice(2, arr.length);
  switch (arr[1]) {
    case "yanghao":
      options.url = yanghaoHttp + arr1.join("/");
      break;
    case "panchen":
      options.url = panchenHttp + arr1.join("/");
      break;
    case "huangying":
      options.url = huangyingHttp + arr1.join("/");
      break;
    case "wangfanghua":
      options.url = wangfanghuaHttp + arr1.join("/");
      break;
    case "huangyi":
      options.url = huangyiHttp + arr1.join("/");
      break;
    case "huyuxin":
      options.url = huyuxinHttp + arr1.join("/");
      break;
  }
  return new Promise((resolve, reject) => {
    // let token=uni.getStorageSync('token');
    Taro.request({
      url: options.url,
      method: options.method || "GET",
      data: options.data || {},
      header: {
        "content-type": "application/json"
        // token
      },
      success: function(res) {
        resolve(res.data);
      },
      fail: function(err) {
        reject(err);
      }
    });
  });
};
export default http;
